<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         * 三种形式：
         * 1.数组的解构赋值
         * 2.对象的解构赋值
         * 3.函数参数的解构赋值
         */
        // 1.数组的解构赋值
        var nums = ['tom','jack','alice']
        // var a = nums[0]
        // var b = nums[1]
        // var c = nums[2]
        var [a,b,c] = nums
        // console.log(a,b,c)

        // 2.对象的解构赋值
        var user = {
            name:'tom',
            age:20,
            sex:'男'
        }
        // var name = user.name
        // var age = user.age
        // var sex = user.sex
        var {name,age,sex} = user
        // console.log(name,age,sex)

        var res = {
            status:200,
            msg:'success',
            data:{
                id:1001,
                username:'admin',
                password:'123'
            }
        }
        var {status,data} = res
        // console.log(status,data)

        // $.ajax({
        //     type:'get',
        //     url:'getUser',
        //     dataType:'json',
        //     success:(res) => {
        //         res.data

        //     },
        // })

       // 3.函数参数的解构赋值
        function f1({name,age}){
            console.log(name)
            console.log(age)
        }
        f1(user)

    </script>
</head>
<body>
    
</body>
</html>